package hanjia;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2025/2/7-下午7:14
 * Since  :   1.0
 * Version:   1.0
 */
public class DFS {

    public void preOrder(TreeNode treeNode){

        if (treeNode==null){
            return;
        }

        System.out.println(treeNode.val);
        preOrder(treeNode.left);
        preOrder(treeNode.right);

    }

    public void midOrder(TreeNode treeNode){

        if (treeNode==null){
            return;
        }


        midOrder(treeNode.left);
        System.out.println(treeNode.val);
        midOrder(treeNode.right);

    }

    public void afterOrder(TreeNode treeNode){

        if (treeNode==null){
            return;
        }


        afterOrder(treeNode.left);

        afterOrder(treeNode.right);
        System.out.println(treeNode.val);

    }






}
